package com.registration.task;

import com.registration.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class CodeTimeoutTask {
    @Autowired
    private UserService userService;
    @Scheduled(fixedRate = 300000)
    public void vitiateCode() {
        try {
            int timeoutMinutes = 10;
            userService.invalidCode(timeoutMinutes);
            System.out.println("已处理超时验证码");
        } catch (Exception e) {
            System.err.println("处理超时验证码任务失败: " + e.getMessage());
            e.printStackTrace();
        }
    }
}
